package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.dto.NursingProjectPageDto;
import com.zzyl.nursing.service.MemberProjectControllerService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/member/orders/")
@RestController
public class MemberProjectController extends BaseController {
    @Autowired
    private MemberProjectControllerService memberProjectControllerService;

    @GetMapping("project/page")
    @ApiOperation(value = "护理项目分页")
    public TableDataInfo<List<NursingProject>> projectPage(@ApiParam(value = "项目查询条件") NursingProjectPageDto nursingProjectPageDto){
        // 显式传入 pageNum 和 pageSize
        startPage(nursingProjectPageDto.getPageNum(), nursingProjectPageDto.getPageSize());
        List<NursingProject> list = memberProjectControllerService.getProjectList(nursingProjectPageDto);
        return getDataTable(list);
    }

    @GetMapping("/project/{id}")
    @ApiOperation(value = "护理项目详情")
    public R<NursingProject> project(@ApiParam(value = "项目ID") @PathVariable Integer id){
        NursingProject nursingProject = memberProjectControllerService.selectProjectById(id);
        return R.ok(nursingProject);
    }
}
